using System;
using System.Collections;
using System.Data;
using System.Data.Common;
using System.Collections.Generic;

using WHC.Pager.Entity;
using Microsoft.Practices.EnterpriseLibrary.Data;
using Carmall.Entity;
using Carmall.IDAL;

namespace Carmall.DAL
{
	/// <summary>
	/// Newscategory 的摘要说明。
	/// </summary>
	public class Newscategory : BaseDAL<NewscategoryInfo>, INewscategory
	{
		#region 对象实例及构造函数

		public static Newscategory Instance
		{
			get
			{
				return new Newscategory();
			}
		}
		public Newscategory() : base("newscategory","CategoryID")
		{
		}

		#endregion

		/// <summary>
		/// 将DataReader的属性值转化为实体类的属性值，返回实体类
		/// </summary>
		/// <param name="dr">有效的DataReader对象</param>
		/// <returns>实体类对象</returns>
		protected override NewscategoryInfo DataReaderToEntity(IDataReader dataReader)
		{
			NewscategoryInfo newscategoryInfo = new NewscategoryInfo();
			SmartDataReader reader = new SmartDataReader(dataReader);
			
			newscategoryInfo.CategoryID = reader.GetInt32("CategoryID");
			newscategoryInfo.CategoryName = reader.GetString("CategoryName");
			newscategoryInfo.ParentID = reader.GetInt32("ParentID");
			newscategoryInfo.Category = reader.GetString("Category");
			
			return newscategoryInfo;
		}

		/// <summary>
		/// 将实体对象的属性值转化为Hashtable对应的键值
		/// </summary>
		/// <param name="obj">有效的实体对象</param>
		/// <returns>包含键值映射的Hashtable</returns>
        protected override Hashtable GetHashByEntity(NewscategoryInfo obj)
		{
		    NewscategoryInfo info = obj as NewscategoryInfo;
			Hashtable hash = new Hashtable(); 
			
			hash.Add("CategoryID", info.CategoryID);
 			hash.Add("CategoryName", info.CategoryName);
 			hash.Add("ParentID", info.ParentID);
 			hash.Add("Category", info.Category);
 				
			return hash;
		}

    }
}